<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <script src="../js/vue2-dev.js"></script>
    </head>
    <body>
        <div id="root">
            <!-- 3.引入自定义组件 -->
            <school></school>
            <student></student>
        </div>
    </body>
    <script>
        Vue.config.productionTip = false;
        // 1.定义组件
        const school = Vue.extend({
            template: `
                <div>
                    <p>{{name}}</p>
                </div>
            `,
            data() {
                return {
                    name: "小哈佛幼儿园",
                };
            },
        });

        // 简写形式，默认会去调用Vue.extend()
        const student = {
            template: `
                <div>
                    <p>{{name}}</p>
                </div>
            `,
            data() {
                return {
                    name: "xuhu",
                };
            },
        };

        // 2.全局注册的方式注册组件
        // Vue.component("school", school);

        const vm = new Vue({
            el: "#root",
            // 2.局部注册的方法交给root这个容器使用
            components: {
                school,
                student,
            },
        });
    </script>
</html>
